import { addAPIProvider, disableCache } from "@iconify/vue";
import SvgIcon from "./svg-icon.vue";
import type { App } from "vue";

interface SvgIconOption {
  iconOrigin?: string;
  iconPrefix?: string;
}

disableCache("all");

const svgIcon = {
  install(app: App, options?: SvgIconOption): void {
    const prefix = options?.iconPrefix;
    if (prefix && options?.iconOrigin) {
      addAPIProvider(prefix, {
        resources: [options?.iconOrigin],
      });
    }
    app.component("SvgIcon", SvgIcon);
  },
};

export default svgIcon;
